package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.config.CreateParamConfigReqDTO;
import com.mingqijia.gassafety.authority.api.req.config.QueryDivisionReqDTO;
import com.mingqijia.gassafety.authority.api.req.config.QueryParamConfigReqDTO;
import com.mingqijia.gassafety.authority.api.req.config.UpdateParamConfigReqDTO;
import com.mingqijia.gassafety.authority.api.resp.config.DivisionLiteRespDTO;
import com.mingqijia.gassafety.authority.api.resp.config.ParamConfigRespDTO;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 参数配置REST接口
 * @author Damon S.
 * @version v1.0.1
 * @date 2021年04月13日 18:42
 */
@Api(tags = "控制台--参数")
@RequestMapping(value = "/console/v1/configs", produces = MediaType.APPLICATION_JSON_VALUE)
public interface ConfigureManageFacade {

    @GetMapping("/divisions")
    @ApiOperation(value = "查询行政区划", notes = "返回行政区划列表")
    PageUtil<DivisionLiteRespDTO> findDivision(@Valid QueryDivisionReqDTO req);

    @GetMapping("/divisions/hierarchy")
    @ApiOperation(value = "行政区化层级结构", notes = "行政区化层级结构")
    List<DivisionLiteRespDTO> findDivisionHierarchy();

    @GetMapping("/divisions/{parentId}")
    @ApiImplicitParam(name = "parentId", value = "父级行政区Id", dataType = "String")
    @ApiOperation(value = "获取子行政区", notes = "获取子行政区")
    List<DivisionLiteRespDTO> findByParentId(@PathVariable String parentId);

    @GetMapping
    @ApiOperation(value = "查询参数配置", notes = "返回参数配置列表")
    PageUtil<ParamConfigRespDTO> findParamConfig(@Valid QueryParamConfigReqDTO req);

    @PostMapping
    @ApiOperation(value = "创建参数配置", notes = "返回是否创建成功")
    String createParamConfig(@RequestBody@Valid CreateParamConfigReqDTO req);

    @PutMapping
    @ApiOperation(value = "更新参数配置", notes = "返回是否更新成功")
    void updateParamConfig(@RequestBody@Valid UpdateParamConfigReqDTO req);

    @DeleteMapping("/{configId}")
    @ApiImplicitParam(name = "configId", value = "参数Id", dataType = "String")
    @ApiOperation(value = "删除参数配置", notes = "返回是否删除成功")
    void removeParamConfig(@PathVariable String configId);

    @PutMapping("/{configId}/{state}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "configId", value = "参数Id", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "启用状态", dataType = "String")
    })
    @ApiOperation(value = "参数配置上下线(0停用，1启用)", notes = "返回是否成功")
    void switchParamConfig(@PathVariable String configId, @PathVariable Integer state);
}
